<?php

if (!class_exists('SMSBase')) {
    require dirname(__FILE__) . '/SMSBase.php';
}
if (!interface_exists('SMSInterface')) {
    require dirname(__FILE__) . '/SMSInterface.php';
}

/**
 *
 * @author lovebing <lovebing365@126.com> Created on 2015-1-11
 */
class SMS {

    /**
     * 漫道
     */
    const CHANNEL_MD = 0;

    /**
     * 吉信通
     */
    const CHANNEL_JXT = 1;
    
    /**
     * 上海创蓝
     */
    const CHANNEL_CL = 2;

    /**
     * 获取实例
     * @param string $user
     * @param string $pwd
     * @param string $sign
     * @param int $channel 0漫道，1吉信通
     * @return Email
     */
    public static function getInstance($user = '', $pwd = '', $sign = null, $channel = self::CHANNEL_MD) {
        $instance = null;
        switch ($channel) {
            case self::CHANNEL_MD:
                if (!class_exists('SMSMD')) {
                    require dirname(__FILE__) . '/SMSMD.php';
                }
                $instance = SMSMD::getInstance($user, $pwd, $sign);
                break;
            case self::CHANNEL_JXT:
                if (!class_exists('SMSJX')) {
                    require dirname(__FILE__) . '/SMSJX.php';
                }
                $instance = SMSJX::getInstance($user, $pwd, $sign);
                break;
            case self::CHANNEL_CL:
                if (!class_exists('SMSCL')) {
                    require dirname(__FILE__) . '/SMSCL.php';
                }
                $instance = SMSCL::getInstance($user, $pwd, $sign);
                break;
        }

        return $instance;
    }

}
